package cn.tedu.sims.config;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;

@Slf4j
@Configuration
public class ValidationConfig {
    public ValidationConfig() {
        log.debug("创建配置类:ValidationConfig");
    }

    @Bean//Spring自动创建类,拿到返回值
    public Validator validation(){
        return Validation.byProvider(HibernateValidator.class)
                .configure()
                .failFast(true)
                .buildValidatorFactory()
                .getValidator();//有一个错误,快速失败,停止检查
    }
}
